package com.knowif.service;

import com.knowif.dao.SettleParamMapper;
import com.knowif.pojo.SettleParam;
import com.knowif.pojo.SettleParamExample;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author ：Xh
 * @date ：Created in 2019/5/25 0025 14:28
 */
@Service
public class SettleParam_service {

    @Autowired
    private SettleParamMapper settleParamMapper;

    /**
     * 通过code查询
     * @param code
     * @return
     */
    public SettleParam selectSettleParamByCode(String code){
        SettleParamExample settleParamExample = new SettleParamExample();
        settleParamExample.createCriteria().andCodeEqualTo(code);
        List<SettleParam> settleParams = settleParamMapper.selectByExample(settleParamExample);
        if(settleParams.size() > 0 && settleParams.size() == 1){
            return settleParams.get(0);
        }
        return null;
    }

    /**
     * 结算参数
     * @param settleParamExample
     * @return
     */
    public List<SettleParam> selectSettleParam(SettleParamExample settleParamExample){
        return settleParamMapper.selectByExample(settleParamExample);
    }

    /**
     * 插入settleParam
     * @param settleParam
     * @return
     */
    public int saveSettleParam(SettleParam settleParam){
        return settleParamMapper.insert(settleParam);
    }

    /**
     * 更新不为空的settleParam属性
     * @param settleParam
     * @return
     */
    public int updateSettleParamNotNull(SettleParam settleParam){
        return settleParamMapper.updateByPrimaryKeySelective(settleParam);
    }

    /**
     * 更新所有settleParam属性
     * @param settleParam
     * @return
     */
    public int updateSettleParam(SettleParam settleParam){
        return settleParamMapper.updateByPrimaryKey(settleParam);
    }

    /**
     * 删除settleParam
     * @param settleParamId
     */
    public int deleteSettleParam(int settleParamId){
        return settleParamMapper.deleteByPrimaryKey(settleParamId);
    }

    /**
     * 根据主键查找
     *
     * */
    public SettleParam selectSettleParamById(int settleParamId){
        return settleParamMapper.selectByPrimaryKey(settleParamId);
    }


}
